package com.gxa.hystrix.interfaces;

import com.gxa.hystrix.pojo.ChuFangMoBan;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

/**
 * @author thinknovo
 * @version 1.0
 * @description ServiceFeignByCheck.java
 * @date 2021/3/11 9:23
 */
// 此接口与feign中定义的接口一样，直接迁移过来即可
// 调用一个子服务模块，需要在注解中指定，名字由client的yml文件定义
@FeignClient(value = "EUREKA-CLIENT-GONGZUOZHAN")
public interface ServiceFeignByChuFangMoBan {
    /*
    这里需要几个要点：
    1.这里定义的路径作用是调用client中的接口
    2.这里的method即是只定义了get，在feign还是会检查client是否允许post请求，如果没有post请求将报错
    3.@RequestParam(value = "name")是绑定controller中的形式参数名，如果没有value属性定义也会报错
     */
    @RequestMapping(value = "/chuFangMoBan/chaXunAll",method = RequestMethod.GET,
            produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    Map chaXunChuFangMoBan(@RequestParam(value = "chuFangLeiXing") String chuFangLeiXing,
                           @RequestParam(value = "moBanBianHao") String moBanBianHao,
                           @RequestParam(value = "moBanMingCheng") String moBanMingCheng,
                           @RequestParam(value = "moBanQuanXian") String moBanQuanXian);

    @RequestMapping(value = "/chuFangMoBan/xinZeng",method = RequestMethod.POST,
            produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    Map xinZengChuFangMoBan(@RequestBody ChuFangMoBan chuFangMoBan);



}
